package Test;

import SocketServer.common.ReqEntity;
import SocketServer.handler.DictHandler;
import org.junit.jupiter.api.Test;

public class DictHandlerTest {

    @Test
    public void findDictTest(){
        DictHandler dictHandler = DictHandler.getInstance();
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setHost( "192.168.0.1" );
        reqEntity.setPort( "3000" );
        reqEntity.setSocketServerApi("findDict");
        reqEntity.setJsonData( "apple" );//查询的单词
        String result = dictHandler.findDict(reqEntity);
        System.out.println(result);
    }

    @Test
    public void insertDictTest(){
        DictHandler dictHandler = DictHandler.getInstance();
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setHost( "192.168.0.1" );
        reqEntity.setPort( "3000" );
        reqEntity.setSocketServerApi("insertDict");
        reqEntity.setJsonData( "apple:苹果" );//新增单词
        String result = dictHandler.insertDict(reqEntity);
        System.out.println(result);

        ReqEntity reqEntity1 = new ReqEntity();
        reqEntity1.setHost( "192.168.0.1" );
        reqEntity1.setPort( "3000" );
        reqEntity1.setSocketServerApi("insertDict");
        reqEntity1.setJsonData( "babala:香蕉" );//新增单词
        String result1 = dictHandler.insertDict(reqEntity1);
        System.out.println(result1);
    }

    @Test
    public void deleteDictTest(){
        DictHandler dictHandler = DictHandler.getInstance();
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setHost( "192.168.0.1" );
        reqEntity.setPort( "3000" );
        reqEntity.setSocketServerApi("deleteDict");
        reqEntity.setJsonData( "apple" );//删除单词
        String result = dictHandler.deleteDict(reqEntity);
        System.out.println(result);
    }

    @Test
    public void updateDictDictTest(){
        DictHandler dictHandler = DictHandler.getInstance();
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setHost( "192.168.0.1" );
        reqEntity.setPort( "3000" );
        reqEntity.setSocketServerApi("updateDict");
        reqEntity.setJsonData( "babala:香菜" );//删除单词
        String result = dictHandler.updateDict(reqEntity);
        System.out.println(result);
    }


    @Test
    public void queryAllDictTest(){
        DictHandler dictHandler = DictHandler.getInstance();
        ReqEntity reqEntity = new ReqEntity();
        reqEntity.setHost( "192.168.0.1" );
        reqEntity.setPort( "3000" );
        reqEntity.setSocketServerApi("queryAllDict");
        reqEntity.setJsonData( "" );//删除单词
        String result = dictHandler.queryAllDict(reqEntity);
        System.out.println(result);
    }



}
